package cn.acewill.yxd.yunxundian.ui.sign;

import android.Manifest;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.location.Location;
import android.location.LocationManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.PersistableBundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.CoordinatorLayout;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.alibaba.fastjson.JSON;
import com.baidu.location.BDLocation;
import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.utils.DistanceUtil;
import com.google.gson.Gson;

import org.xutils.ex.DbException;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import cn.acewill.yxd.yunxundian.BaseActivity;
import cn.acewill.yxd.yunxundian.R;
import cn.acewill.yxd.yunxundian.adapter.EditEvaAdapter;
import cn.acewill.yxd.yunxundian.adapter.EvaMajorItemSelectAdapter;
import cn.acewill.yxd.yunxundian.adapter.LeftMenuAdapter;
import cn.acewill.yxd.yunxundian.adapter.RightMenuAdapter;
import cn.acewill.yxd.yunxundian.componet.CheckDataDialog;
import cn.acewill.yxd.yunxundian.model.ChongFuKouFen;
import cn.acewill.yxd.yunxundian.model.CommonMapBean;
import cn.acewill.yxd.yunxundian.model.RMain;
import cn.acewill.yxd.yunxundian.model.Schedule;
import cn.acewill.yxd.yunxundian.model.Shop;
import cn.acewill.yxd.yunxundian.model.SignUpInfo;
import cn.acewill.yxd.yunxundian.model.tempLostRR;
import cn.acewill.yxd.yunxundian.pubClass.AsynData;
import cn.acewill.yxd.yunxundian.pubClass.OkHttpManger;
import cn.acewill.yxd.yunxundian.pubClass.RMainUtils;
import cn.acewill.yxd.yunxundian.pubClass.pubClass;
import cn.acewill.yxd.yunxundian.ui.MainActivity;
import cn.acewill.yxd.yunxundian.ui.sign.Contract.EditModel;
import cn.acewill.yxd.yunxundian.ui.sign.Presenter.EditPresenterIml;
import cn.acewill.yxd.yunxundian.ui.user.YxdAbstractPhtotoActivity;
import cn.acewill.yxd.yunxundian.utils.CacheActivity;
import cn.acewill.yxd.yunxundian.utils.MaterialDialogUtils;
import cn.acewill.yxd.yunxundian.utils.baiduUtils.BaiduMapUtils;

/**
 * Created by xxx on 2018/1/11.
 * 新的评估编辑页面
 */

public class EditEvaluationActivity extends YxdAbstractPhtotoActivity implements EditModel,View.OnClickListener,SearchView.OnQueryTextListener {

    private static final int BACK_UP_UPDATE = 100;
    private static final int PREVIEW_UPDATE = 101;

    private DrawerLayout mDrawLayout;
    private ActionBarDrawerToggle mToggle;
    //滑动菜单
    private RecyclerView myRecycle;
    private EditPresenterIml presenterIml;
    private EditEvaAdapter adapter;
    //头部控件
 //   private NormalDecoration decoration;
    //  private boolean needMove = false;
  //  private int movePosition;
    //弹出体
    private ListView popListView;
    private int schId;
    private RMain.TablesBean.RowsBean.Q2Bean minBean;
    private String shopName = "";
    private LinearLayout leftLiner;
    private CoordinatorLayout mainLiner;
    private TextView majorView, pointView;
    //leftMenu
    private TextView lf_majorName, lf_allPointItem;
    private ListView leftMenu;
    private LeftMenuAdapter leftAdapter;
    //rightMenu
    private ListView rightMenu;
    private RightMenuAdapter rightAdapter;
    private TextView rg_majorName;
    private String[] rg_data = {"评估提示", "基本信息", "问题追踪", "门店签字"};
    //数据
    private List<RMain.TablesBean.Q1Bean> q1List = new ArrayList<>();

    //上次大项的position
    private int selPosition = 0;

    private TextView titleText;
    //小项编辑的数量
    private TextView dataCount;

    //内存放入部分数据，避免重复查询
    private int allPointCount = 0;//所有关键项个数
    private String majorName; //大项名称
    private List<RMain> rMains; //评估表



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.base_drawlayout);
        CacheActivity.addActivity(this);
        //实现侧滑菜单状态栏透明
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//            getWindow().setStatusBarColor(Color.TRANSPARENT);
//            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
//        }

        initView();
    }

    @Override
    protected void onResume() {
        super.onResume();
        try {
            checkCanDoReport();
        } catch (DbException e) {
            e.printStackTrace();
        }
    }

    private void initView() {
        schId = getIntent().getIntExtra("schId", 0);
        Schedule schedule = null;
        try {
            schedule = db.selector(Schedule.class).where("ID", "=", schId).findFirst();
            int shopId = schedule.getShopID();
            if (shopId > 0) {
                Shop shop = db.selector(Shop.class).where("ID", "=", shopId).findFirst();
                shopName = shop.getShopName();
            }
        } catch (DbException e) {
            e.printStackTrace();
        }
        Toolbar toolbar = findViewById(R.id.myToolBar);
        toolbar.setTitle("");
        titleText = findViewById(R.id.titleText);
        majorView = findViewById(R.id.majorView);
        dataCount = findViewById(R.id.dataCount);
        pointView = findViewById(R.id.pointView);
        pointView.setOnClickListener(this);
        ImageView menuControl =findViewById(R.id.menuControl);
        menuControl.setOnClickListener(this);
        SearchView searchView = findViewById(R.id.search_bar);
        searchView.setOnQueryTextListener(this);
        myRecycle = findViewById(R.id.myRecycle);
        LinearLayoutManager lManger = new LinearLayoutManager(this);
        myRecycle.setLayoutManager(lManger);
        mDrawLayout = findViewById(R.id.dl_left);
        leftMenu = findViewById(R.id.lv_left_menu);
        leftLiner = findViewById(R.id.leftLinear);
        leftLiner.setOnClickListener(this);
        mainLiner = findViewById(R.id.mainLiner);
        initLeftMenu();
        initRightMenu();

        popListView = new ListView(this);
        popListView.setBackgroundColor(ContextCompat.getColor(this, R.color.gray));
        mToggle = new ActionBarDrawerToggle(this, mDrawLayout, toolbar, R.string.draw_open, R.string.draw_close) {
            @Override
            public void onDrawerOpened(View drawerView) {
                super.onDrawerOpened(drawerView);
                if (mDrawLayout.isDrawerOpen(Gravity.START)) {
                    //此处不能进行左侧视图刷新，导致view’s bound damage，平移会回到原点
                } else {
                    //右侧打开打开手势活动
                    mDrawLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.END);
                }
            }
            @Override
            public void onDrawerClosed(View drawerView) {
                super.onDrawerClosed(drawerView);
                mDrawLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.END);
            }
        };
        mToggle.syncState();
        mDrawLayout.addDrawerListener(mToggle);
        mDrawLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.END);
        presenterIml = new EditPresenterIml(this);

        presenterIml.loadLocalData(schId);
        presenterIml.loadRepeatLost(schId);
        toolbar.setNavigationIcon(R.mipmap.icon_back);
        setSupportActionBar(toolbar);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        //打开监听
        mDrawLayout.addDrawerListener(new DrawerLayout.DrawerListener() {
            @Override
            public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
              setLayoutSlide();
            }

            @Override
            public void onDrawerOpened(@NonNull View drawerView) {
            }

            @Override
            public void onDrawerClosed(@NonNull View drawerView) {

            }

            @Override
            public void onDrawerStateChanged(int newState) {

            }
        });
        //去掉阴影
        mDrawLayout.setScrimColor(Color.TRANSPARENT);


    }

    public void initLeftMenu() {
        leftLiner = findViewById(R.id.leftLiner);
        leftMenu = findViewById(R.id.lv_left_menu);
        lf_majorName = findViewById(R.id.majorName);
        lf_allPointItem = findViewById(R.id.allPointItem);
        TextView allItem = findViewById(R.id.allItem);
        allItem.setOnClickListener(this);
        TextView findAllPoint = findViewById(R.id.findAllPoint);
        findAllPoint.setOnClickListener(this);

    }

    public void initRightMenu() {
        rg_majorName = findViewById(R.id.rg_majorName);
        rightMenu = findViewById(R.id.rightList);
        TextView preview = findViewById(R.id.preview);
        preview.setOnClickListener(this);
        TextView submit = findViewById(R.id.submitData);
        submit.setOnClickListener(this);
    }
    public void setLayoutSlide(){
        WindowManager manager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
        assert manager != null;
        Display display = manager.getDefaultDisplay();
        //设置右面的布局位置  根据左面菜单的right作为右面布局的left   左面的right+屏幕的宽度（或者right的宽度这里是相等的）为右面布局的right
        mainLiner.layout(leftLiner.getRight(),0,leftLiner.getRight()+display.getWidth(),display.getHeight());
        Log.e("addDrawerListener",leftLiner.getRight()+"");
    }


    public void refreshScore(final int schid,final List<RMain.TablesBean.RowsBean.Q2Bean> q2Beans)throws DbException
    {
        new Thread(new Runnable() {
            @Override
            public void run() {
                final String point = "关键项(" + RMainUtils.getInstance().getPointCountByQ2Beans(q2Beans, schId)+ ")";
                final String data = "("+RMainUtils.getInstance().getWriteByQ2Beans(schid,q2Beans)+"/"+q2Beans.size()+")";
                String retStr = "";
                HashMap<Integer,String> valueMap = new HashMap<>();
                try {
                     retStr = pubClass.calScoreBySch(schid);
                    valueMap = pubClass.tableScore;
                } catch (DbException e) {
                    e.printStackTrace();
                }
                final String finalRetStr = retStr;
                final HashMap<Integer, String> finalValueMap = valueMap;
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                            pointView.setText(point);
                            dataCount.setText(data);
                            if (finalRetStr !=null&&!TextUtils.isEmpty(finalRetStr)){
                                titleText.setText(finalRetStr);
                            }
                            leftAdapter.setValueMap(finalValueMap);
                            leftAdapter.notifyDataSetChanged();
                       
                    }
                });
            }
        }).start();
    }


//    @Override
//    public boolean onCreateOptionsMenu(Menu menu) {
//        getMenuInflater().inflate(R.menu.menu_edit_search, menu);
//        return super.onCreateOptionsMenu(menu);
//    }
//
//    @Override
//    public boolean onOptionsItemSelected(MenuItem item) {
//        switch (item.getItemId()) {
//            case R.id.menuControl:
//                if (mDrawLayout.isDrawerOpen(Gravity.RIGHT)) {
//                    mDrawLayout.setStatusBarBackground(R.color.blue);
//                    mDrawLayout.closeDrawer(Gravity.RIGHT);
//                } else {
//                    mDrawLayout.setStatusBarBackground(R.color.design_toolBar_gray);
//                    mDrawLayout.openDrawer(Gravity.RIGHT);
//                }
//                break;
//        }
//        return super.onOptionsItemSelected(item);
//    }

    //重写此方法实现动画效果
    @Override
    public void onPostCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
        super.onPostCreate(savedInstanceState, persistentState);
        mToggle.syncState();
    }

    @Override
    public void updateAdapter(final List<RMain> rMains, final List<RMain.TablesBean.Q1Bean> q1Beans, final List<RMain.TablesBean.RowsBean.Q2Bean> q2Beans) {
        //  ScoreCheckBoxAdapter adapter = new ScoreCheckBoxAdapter(this,q2,rowsBeans,schId);
//        List<ScoreCheckBoxAdapter> adapterList = new ArrayList<>();
//        for (RMain.TablesBean.RowsBean.Q2Bean q2Bean : q2Beans) {
//            ScoreCheckBoxAdapter adapter = new ScoreCheckBoxAdapter(this,q2Bean,getItemsByRrowid(rMains,q2Bean.getID()),schId);
//            try {
//                tempLostRR  rr = db.selector(tempLostRR.class).where("schId","=",schId).and("rRowId","=",q2Bean.getID()).findFirst();
//                if (rr!=null){
//                    if (rr.getScoreType()==1){
//                        for (int k = 0;k<getItemsByRrowid(rMains,q2Bean.getID()).size();k++){
//                            if (getItemsByRrowid(rMains,q2Bean.getID()).get(k).getID()==rr.getSelectItemId()){
//                                getItemsByRrowid(rMains,q2Bean.getID()).get(k).setCheck(true);
//                                break;
//                            }
//                        }
//                    }
//                }
//            } catch (DbException e) {
//                e.printStackTrace();
//            }
//
//            adapterList.add(adapter);
//        }

//
//        decoration = new NormalDecoration() {
//            @Override
//            public String getHeaderName(int pos) {
//                RMain.TablesBean.RowsBean.Q2Bean bean = q2Beans.get(pos);
//                return  presenterIml.getQ1ByRow(bean);
//            }
//        };
//        //头部点击事件
//        decoration.setOnHeaderClickListener(new NormalDecoration.OnHeaderClickListener() {
//            @Override
//            public void headerClick(int pos) {
//                majorSelectView();
//            }
//        });
//        //绘制自定义头部
//        decoration.setOnDecorationHeadDraw(new NormalDecoration.OnDecorationHeadDraw() {
//            @Override
//            public View getHeaderView(int pos) {
//                View view = LayoutInflater.from(EditEvaluationActivity.this).inflate(R.layout.eva_head_view,null);
//                TextView headView = (TextView) view.findViewById(R.id.headName);
//                headView.setText(presenterIml.getQ1ByRow(q2Beans.get(pos)));
//                TextView headCount = (TextView) view.findViewById(R.id.headCount);
//                headCount.setText(presenterIml.getPostionCount(q2Beans.get(pos)));
//                return view;
//            }
//        });
//        myRecycle.addItemDecoration(decoration);

        //先存好数据，不用每次点击new
//        final EvaMajorItemSelectAdapter adapter = new EvaMajorItemSelectAdapter(this,q1Beans);
//        listView.setAdapter(adapter);
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
//
//            myRecycle.setOnScrollChangeListener(new View.OnScrollChangeListener() {
//                @Override
//                public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
//                    Log.e("scorlle","============1");
//                    if (needMove){ //特殊滑动处理
//                        needMove = false;
//                        int n = movePosition - lManger.findFirstVisibleItemPosition();
//                        if (0 <= n && n<myRecycle.getChildCount()){
//                            //获取要置顶的项顶部离RecyclerView顶部的距离
//                            int top = myRecycle.getChildAt(n).getTop()-dip2px(EditEvaluationActivity.this,30);
//                            //最后的移动
//                            myRecycle.scrollBy(0, top);
//                        }
//                    }
//                }
//            });
//        }else{
//            myRecycle.setOnScrollListener(new RecyclerView.OnScrollListener() {
//                @Override
//                public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
//                    super.onScrolled(recyclerView, dx, dy);
//                    Log.e("scorlle", "============2");
//                    if (needMove) { //特殊滑动处理
//                        needMove = false;
//                        int n = movePosition - lManger.findFirstVisibleItemPosition();
//                        if (0 <= n && n < myRecycle.getChildCount()) {
//                            //获取要置顶的项顶部离RecyclerView顶部的距离
//                            int top = myRecycle.getChildAt(n).getTop()-dip2px(EditEvaluationActivity.this,30);
//                            //最后的移动
//                            myRecycle.scrollBy(0, top);
//                        }
//                    }
//                }
//            });
//        }

        if (rMains==null){
            showToast(this,"数据错误");
            finish();
            return;
        }
        q1List = q1Beans;
        this.rMains = rMains;
        allPointCount = RMainUtils.getInstance().getPointItemCount(rMains);
        setEditAdapter(rMains, q2Beans);
//        SpannableString span = new SpannableString(q1Beans.get(0).getReportTableName() + "(1/" + q1Beans.size() + ")");
//        span.setSpan(new ForegroundColorSpan(Color.parseColor("#019CEC")), 0, q1Beans.get(0).getReportTableName().length(), SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
        setMajorView(q1Beans.get(0).getReportTableName());
        majorName = q1Beans.get(0).getReportTableName();

        //初始化左侧listview
        leftAdapter = new LeftMenuAdapter(this, q1Beans, rMains, schId);
        leftMenu.setAdapter(leftAdapter);
        leftMenu.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
                leftAdapter.setSelectItem(position);
                selPosition = position;
                mDrawLayout.closeDrawer(Gravity.START);
                //延时0.5s加载数据，让mdrawLayou关闭动画执行完毕
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        presenterIml.loadMinListByPosition(position);
                    }
                },400);
//                SpannableString span = new SpannableString(q1Beans.get(position).getReportTableName() + "(" + (position + 1) + "/" + q1List.size() + ")");
//                span.setSpan(new ForegroundColorSpan(Color.parseColor("#019CEC")), 0, q1Beans.get(position).getReportTableName().length(), SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
                majorName = q1Beans.get(position).getReportTableName();
            }
        });
        lf_majorName.setText(rMains.get(0).getQ().getShortName());
        lf_allPointItem.setText("全部关键项(" + RMainUtils.getInstance().getAllWritePointCount(rMains, schId) + "/" + allPointCount + ")");
        //选择弹出框数据初始化
        final EvaMajorItemSelectAdapter adapter = new EvaMajorItemSelectAdapter(this, q1Beans);
        popListView.setAdapter(adapter);

        //初始化右侧listview
        rg_majorName.setText(lf_majorName.getText());
        RMain.QBean qBean = rMains.get(0).getQ();
        rightAdapter = new RightMenuAdapter(this, rg_data, qBean);

        rightMenu.setAdapter(rightAdapter);
        rightMenu.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (position == 0) {
                    rightAdapter.setSelectItem(position);
                    rightAdapter.notifyDataSetChanged();
                } else if (position == 1) { //基本信息
                    startActivity(new Intent(EditEvaluationActivity.this, JibenInfoActivity.class)
                            .putExtra("schid", schId).putExtra("mainId", rMains.get(0).getQ().getID()));
                } else if (position == 2) { //问题追踪
                    startActivity(new Intent(EditEvaluationActivity.this, MulitpleLostRRActivity.class).putExtra("schid", schId));
                } else if (position == 3) {//门店签字
                    shopSignIntent();
                }
            }
        });
    }

    //leftmenu 点击刷新
    @Override
    public void refreshAdapterByPosition(List<RMain> rMains, List<RMain.TablesBean.RowsBean.Q2Bean> q2Beans) {
     //   majorView.setText(majorName);
        setMajorView(majorName);
        setEditAdapter(rMains, q2Beans);
    }

    //检索搜索数据
    @Override
    public void searchDataByMinName(List<RMain> rMains, List<RMain.TablesBean.RowsBean.Q2Bean> q2Beans) {
        setEditAdapter(rMains, q2Beans);
    }

    //重复扣分数据
    @Override
    public void setChongFuKouFen(List<ChongFuKouFen> kouFens) {
        if (kouFens!=null&&kouFens.size()>0){
            if (adapter!=null){
                adapter.getChongFu(kouFens);
                adapter.notifyDataSetChanged();
            }
        }
    }

    @Override
    public void loadRmainErro() {
        BaseActivity.showToast(this,"通用任务评估表被禁用，请执行其他任务");
        finish();
    }

    public void setMajorView(String str){
        if (str.length()>7){
            majorView.setText(str.substring(0, 6) + "..");
        }else{
            majorView.setText(str);
        }
    }

    //设置主页适配器
    public void setEditAdapter(final List<RMain> rMains, List<RMain.TablesBean.RowsBean.Q2Bean> q2Beans) {

        adapter = new EditEvaAdapter(this, schId, rMains, q2Beans, new EditEvaAdapter.OnItemClickListener() {
            @Override
            public void onBackUpClick(RMain.TablesBean.RowsBean.Q2Bean q2Bean) {
                minBean = q2Bean;

                try {
                    tempLostRR rr = db.selector(tempLostRR.class).where("schId", "=", schId)
                            .and("rRowId", "=", q2Bean.getID()).findFirst();
                    if (rr!=null){
                        startActivityForResult(new Intent(EditEvaluationActivity.this, EvaBackUpActivity.class)
                                .putExtra("q2Bean", q2Bean).putExtra("schId", schId).putExtra("name",majorName), BACK_UP_UPDATE);
                    }else{
                        BaseActivity.showToast(EditEvaluationActivity.this,"请先选或填写分数");
                    }
                } catch (DbException e) {
                    e.printStackTrace();
                }
            }
            @Override
            public void onAddPictureClick(RMain.TablesBean.RowsBean.Q2Bean q2Bean) {
                try {
                    minBean = q2Bean;
                    int maxJpgCount;
                    tempLostRR rr = db.selector(tempLostRR.class).where("schId", "=", schId)
                            .and("rRowId", "=", q2Bean.getID()).findFirst();
                    if (rr != null) {
                        maxJpgCount = getSelectJpgCount(rr);
                     if (maxJpgCount == 9){  //没照片跳转拍照
                            showPopWin(EditEvaluationActivity.this, shopName, true, maxJpgCount);
                        }else{  //含有则进入备注
                            startActivityForResult(new Intent(EditEvaluationActivity.this, EvaBackUpActivity.class)
                                    .putExtra("q2Bean", q2Bean).putExtra("schId", schId).putExtra("name",majorName), BACK_UP_UPDATE);
                        }
                    }else{
                        BaseActivity.showToast(EditEvaluationActivity.this,"请先选或填写分数");

                    }
                } catch (DbException e) {
                    e.printStackTrace();
                }
            }
            @Override
            public void onAddVideoClick(RMain.TablesBean.RowsBean.Q2Bean q2Bean) {
                try {
                    minBean = q2Bean;
                    tempLostRR rr = db.selector(tempLostRR.class).where("schId", "=", schId)
                            .and("rRowId", "=", q2Bean.getID()).findFirst();
                    if (rr != null) {
                        if (rr.getVideoStr() != null && rr.getVideoStr().length() > 0) {
                            startActivityForResult(new Intent(EditEvaluationActivity.this, EvaBackUpActivity.class)
                                    .putExtra("q2Bean", q2Bean).putExtra("schId", schId).putExtra("name",majorName), BACK_UP_UPDATE);
                        }else{
                            showVideoPop(EditEvaluationActivity.this);
                        }
                    }else{
                        BaseActivity.showToast(EditEvaluationActivity.this,"请先选或填写分数");
                    }
                } catch (DbException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onAddScoreClick(List<RMain.TablesBean.RowsBean.Q2Bean> q2Beans) {
                //执行分数的刷新及关键项的刷新
                lf_allPointItem.setText("全部关键项(" + RMainUtils.getInstance().getAllWritePointCount(rMains, schId) + "/" + allPointCount + ")");
                try {
                    refreshScore(schId,q2Beans);
                } catch (DbException e) {
                    e.printStackTrace();
                }

            }

            @Override  //输入分数执行的刷新分数
            public void onInputScoreListener(List<RMain.TablesBean.RowsBean.Q2Bean> q2Beans) {
                lf_allPointItem.setText("全部关键项(" + RMainUtils.getInstance().getAllWritePointCount(rMains, schId) + "/" + allPointCount + ")");
                try {
                    refreshScore(schId,q2Beans);
                } catch (DbException e) {
                    e.printStackTrace();
                }
            }
        });
        myRecycle.setAdapter(adapter);
        //刷新分数及item的编辑项
        try {
            refreshScore(schId,q2Beans);
        } catch (DbException e) {
            e.printStackTrace();
        }
    }


//    public void majorSelectView(View view) {
//
//        final SpinnerPopWin popWin = SpinnerPopWin.getInstance(this, popListView);
//        popWin.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
//        popWin.setWidth(view.getWidth());
//        popWin.showPopupWindow(view);
//        popListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//            @Override
//            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//                popWin.dismiss();
//                RMain.TablesBean.Q1Bean q1Bean = (RMain.TablesBean.Q1Bean) parent.getItemAtPosition(position);
//                showToast(EditEvaluationActivity.this, q1Bean.getReportTableName());
//                //滑动到其他位置
//                //      setScroller(position);
//                presenterIml.loadMinListByPosition(position);
//                SpannableString span = new SpannableString(q1Bean.getReportTableName() + "(" + (position + 1) + "/" + q1List.size() + ")");
//                span.setSpan(new ForegroundColorSpan(Color.parseColor("#019CEC")), 0, q1Bean.getReportTableName().length(), SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
//                majorView.setText(span);
//            }
//        });
//    }


    /*计算选取的照片的额数量*/
    public int getSelectJpgCount(tempLostRR rr) {
        if (rr.getJpgStr() != null && rr.getJpgStr().length() > 0) {
            String[] array = rr.getJpgStr().split(",");
            if (array.length < 9) {
                return 9 - array.length;
            } else {
                return 0;
            }
        } else {
            return 9;

        }
    }
//
//    /**
//     * 处理滑动
//     * 屏幕可见的itemPosition小于特殊处理
//     * 屏幕可见大于是直接滑动
//     * getChildeAt 只能拿到屏幕显示的部分view（-fistVisibleItem）
//     *
//     * @param position 点击position
//     */
//    public void setScroller(int position) {
//        //滑动的position
//        int index = presenterIml.getTypeByPosition(position);
//        //屏幕的第一个position 与最后一个position
//        int fistItem = lManger.findFirstVisibleItemPosition();
//        int lastItem = lManger.findLastVisibleItemPosition();
//        //区分情况
//        if (index <= fistItem) { //顶部
//            myRecycle.scrollToPosition(index);
//        } else if (index <= lastItem) {  //屏幕内
//            int top = myRecycle.getChildAt(index - fistItem).getTop() - DensityUtil.dip2px(EditEvaluationActivity.this, 30);
//            myRecycle.scrollBy(0, top);
//        } else { //下方显示
//            myRecycle.scrollToPosition(index);
//            needMove = true;
//            movePosition = index;
//
//        }
//
//    }

    //返回的图片数据
    @Override
    public void onPhotoSelected(String resultPath) {
        try {
            tempLostRR rr = db.selector(tempLostRR.class).where("schId", "=", schId)
                    .and("rRowId", "=", minBean.getID()).findFirst();
            if (rr != null) {
                if (rr.getJpgStr() != null) {
                    rr.setJpgStr(rr.getJpgStr() + resultPath);
                } else {
                    rr.setJpgStr(resultPath);
                }
                db.saveOrUpdate(rr);
                adapter.notifyDataSetChanged();
            } else {
                showToast(this, "数据错误,请先添加分数");
            }
        } catch (DbException e) {
            e.printStackTrace();
        }
    }
    Gson gson = new Gson();
    @Override
    public void onVideoRecode(String resultPath) {
        try {
            tempLostRR rr = db.selector(tempLostRR.class).where("schId", "=", schId)
                    .and("rRowId", "=", minBean.getID()).findFirst();
            if (rr != null) {
                if (resultPath.length() > 0) {
                    rr.setVideoStr(resultPath);
                    db.saveOrUpdate(rr);
                    adapter.notifyDataSetChanged();
                    Log.e("temprrupdate",gson.toJson(rr));
                }
            } else {
                showToast(this, "数据错误,请先添加分数");
            }
        } catch (DbException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.findAllPoint://去看看
                final List<RMain.TablesBean.RowsBean.Q2Bean> q2List = RMainUtils.getInstance().getPointItem(rMains);
                if (q2List!=null&&q2List.size()>0){
                    mDrawLayout.closeDrawer(Gravity.LEFT);
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            majorView.setText("全部");
                            setEditAdapter(rMains,q2List);
                        }
                    },400);
                }else{
                    BaseActivity.showToast(this,"当前评估表无关键项");
                }
                break;
            case R.id.allItem: //全部大项（display all item）
                final List<RMain.TablesBean.RowsBean.Q2Bean> q2Beans = RMainUtils.getInstance().getAllQ2Bean(rMains);

                if (q2Beans!=null&&q2Beans.size()>0){
                    mDrawLayout.closeDrawer(Gravity.START);
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            majorView.setText("全部");
                            setEditAdapter(rMains,q2Beans);
                        }
                    },400);

                }else{
                    BaseActivity.showToast(this,"无可读数据");
                }
                break;
            case R.id.menuControl: //右侧抽屉开关
                if (mDrawLayout.isDrawerOpen(Gravity.END)) {
                    mDrawLayout.setStatusBarBackground(R.color.blue);
                    mDrawLayout.closeDrawer(Gravity.END);
                } else {
                    mDrawLayout.setStatusBarBackground(R.color.design_toolBar_gray);
                    mDrawLayout.openDrawer(Gravity.END);
                }
                break;
            case R.id.leftLinear: //选择大项
                //    majorSelectView(majorView);
                if (!mDrawLayout.isDrawerOpen(Gravity.START)) {
                    mDrawLayout.openDrawer(Gravity.START);
                }
                break;
            case R.id.preview: //预览
                startActivityForResult(new Intent(this, PreViewAcitivity.class).putExtra("schId", schId),PREVIEW_UPDATE);
                break;
            case R.id.submitData: //提交

                boolean[] falg = CheckDataDialog.getInstance(this).checkDataComplete(schId,rMains);
                if (falg!=null){
                    showTipDialog(falg);
                }else{
                    BaseActivity.showToast(this,"数据错误");
                }
                //   startActivity(new Intent(this, SendMailActivity.class).putExtra("schId", schId));
                break;
            //tipDialog
            case R.id.addFollow: //问题跟踪
                startActivity(new Intent(EditEvaluationActivity.this, MulitpleLostRRActivity.class)
                        .putExtra("schid", schId));
                break;
            case R.id.shopSign: //签到
                shopSignIntent();
                break;
            case R.id.gotoSubmit: //提交
                startActivity(new Intent(this,SendMailActivity.class).putExtra("schId",schId));
                break;
        }
    }

    @Override
    public boolean onQueryTextSubmit(String query) {
        return false;
    }

    @SuppressLint("SetTextI18n")
    @Override
    public boolean onQueryTextChange(String newText) {
        if (TextUtils.isEmpty(newText)) {
            presenterIml.loadMinListByPosition(selPosition);
            majorView.setText(majorName);
            leftAdapter.setSelectItem(selPosition);
        } else {
            presenterIml.searchMinItem(newText);
            majorView.setText("全部");
            //不让左侧被选中
            leftAdapter.setSelectItem(-1);
        }
        return false;
    }

    public void shopSignIntent() {
        Intent in = new Intent(this, SignActivity.class);
        in.putExtra("rrschid", schId);
        startActivity(in);
    }
    //未填写数据的提示
    private void showTipDialog(boolean[] need){
        if (!need[0]&&!need[1]&&!need[2]){
            startActivity(new Intent(this,SendMailActivity.class).putExtra("schId",schId));
        }else{
            final Dialog dialog= new Dialog(this,R.style.mydialog);
            View view = LayoutInflater.from(this).inflate(R.layout.eva_check_dialog, (ViewGroup) getWindow().getDecorView(),false);
            TextView addFollow = view.findViewById(R.id.addFollow);
            TextView shopSign = view.findViewById(R.id.shopSign);
            TextView gotoSubmit = view.findViewById(R.id.gotoSubmit);
            TextView jiBenData = view.findViewById(R.id.jiBenData);
            gotoSubmit.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                    startActivity(new Intent(EditEvaluationActivity.this,SendMailActivity.class)
                            .putExtra("schId",schId));
                }
            });
            TextView cancel_action = view.findViewById(R.id.cancel_action);
            cancel_action.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            });
            if (!need[0]){
                addFollow.setVisibility(View.GONE);
            }
            if (!need[1]){
                shopSign.setVisibility(View.GONE);
            }
            if (!need[2]){
                jiBenData.setVisibility(View.GONE);
            }
            dialog.setContentView(view);
            dialog.setCancelable(true);
            dialog.show();
        }
    }

    //关键项填写的dialog
    private void showPointDialog(){
        mDrawLayout.closeDrawer(Gravity.RIGHT);
        final Dialog dialog= new Dialog(this,R.style.mydialog);
        View view = LayoutInflater.from(this).inflate(R.layout.eva_point_dialog,(ViewGroup)getWindow().getDecorView(),false);
        TextView addRR = view.findViewById(R.id.addRR);
        addRR.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        TextView exit = view.findViewById(R.id.exit);
        exit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                finish();
            }
        });
        dialog.setContentView(view);
        dialog.setCancelable(true);
        dialog.show();

    }



    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode){
            case BACK_UP_UPDATE:

            case PREVIEW_UPDATE:
                if (adapter!=null){
                    adapter.notifyDataSetChanged();
                }
                break;
        }
    }
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {

        if (keyCode == KeyEvent.KEYCODE_BACK){
            if (mDrawLayout.isDrawerOpen(Gravity.START)){
                mDrawLayout.closeDrawer(Gravity.START);
                return true;
            }else if (mDrawLayout.isDrawerOpen(Gravity.END)){
                mDrawLayout.closeDrawer(Gravity.END);
                return true;
            }else{
                finish();
                return false;
            }
        }
        return false;
    }


    /**
     * 签到的模块
     *
     */
    private LatLng myPosition;
    private boolean isFirstLoc = true;
    private Dialog dialog;
    private int isinrange = 0;
    private int isneedupdateshopXY = 1;
    private int shopId;
    private TextView countText;


    public void checkCanDoReport() throws DbException
    {
        if(schId==0)
            jiuyuanSchid();
        final Schedule thisSch=db.selector(Schedule.class).where("ID","=",schId+"").findFirst();

        if(thisSch.getShopID()>0)
        {
            if(thisSch.getStates()==1) {
                SignUpInfo sui = db.selector(SignUpInfo.class).where("shopId", "=", thisSch.getShopID())
                        .and("empId","=", MainActivity.id)
                        .and("outTime","=",null)
                        .findFirst();
                if(sui==null){

                    MaterialDialogUtils.showMoreBtnDialog(this, "当前门店没进行签到，是否去该门店签到？" + "\n" + "tip：签到才能执行任务",
                            "地图查看", "取消", "直接签到", false, true,
                            new MaterialDialog.SingleButtonCallback() {
                                @Override
                                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                    try {
                                        Shop shop = db.selector(Shop.class).where("ID","=",thisSch.getShopID()).findFirst();
                                        Intent in=new Intent(EditEvaluationActivity.this,SignInActivity.class).putExtra("shopId",thisSch.getShopID());
                                        in.putExtra("xcol",shop.getxCol());
                                        in.putExtra("ycol", shop.getyCol());
                                        in.putExtra("schid",schId);
                                        in.putExtra("shopName", shop.getShopName());
                                        startActivity(in);
                                    } catch (DbException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }, new MaterialDialog.SingleButtonCallback() {
                                @Override
                                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                    dialog.dismiss();
                                    finish();
                                }
                            }, new MaterialDialog.SingleButtonCallback() {
                                @Override
                                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                    signLocation();
                                    showSignDialog();
                                }
                            });
                }
                else{
                    freshSchStatus(thisSch);
                }
            }
        }
    }
    public void freshSchStatus(Schedule thisSch){
        thisSch.setStates(2);
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
        String thistime=df.format(new Date());
        thistime=thistime.replace(" ","T");
        thisSch.setRealStartTime(thistime);
        try {
            db.saveOrUpdate(thisSch);
        } catch (DbException e) {
            e.printStackTrace();
        }
    }

    public void jiuyuanSchid()
    {
        try {
            CommonMapBean gudingSch=db.selector(CommonMapBean.class).where("cmType","=","gudingsch").findFirst();
            if(gudingSch!=null)
            {
                schId=Integer.getInteger(gudingSch.getCmValue(),0);
            }
            else
                schId=0;
        } catch (DbException e) {
            e.printStackTrace();
        }
    }


    //开启定位
    int count = 0;
    private void signLocation(){
        BaiduMapUtils.getInstance(this).getLocate(new BaiduMapUtils.OnLocationMapListener() {
            @Override
            public void getCurrLocation(BDLocation location) throws DbException {
//                MyLocationData locData = new MyLocationData.Builder()
//                        .accuracy(location.getRadius())
//                        // 此处设置开发者获取到的方向信息，顺时针0-360
//                        .direction(100).latitude(location.getLatitude())
//                        .longitude(location.getLongitude()).build();
                myPosition = new LatLng(location.getLatitude(), location.getLongitude());
                Log.e("myPosition",myPosition+"");
                if (isFirstLoc) {
                    isFirstLoc = false;
                    if ((int) location.getAltitude() == 0) {
                        LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
                        if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                            if (ActivityCompat.checkSelfPermission(EditEvaluationActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(EditEvaluationActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                                return;
                            }
                            Location mlocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                            if (mlocation != null) {
                                double[] latlng = (pubClass.wgs2bd(mlocation.getLatitude(), mlocation.getLongitude()));
                                myPosition = new LatLng(latlng[0], latlng[1]);
                                Log.e("myPosition",myPosition+"");
//                                locData = new MyLocationData.Builder()
//                                        .accuracy(location.getRadius())
//                                        // 此处设置开发者获取到的方向信息，顺时针0-360
//                                        .direction(100).latitude(latlng[0])
//                                        .longitude(latlng[1]).build();
                            }
                        }
                    }
                }
                if (!isFirstLoc&&myPosition.latitude!=0&&myPosition.longitude!=0) signIn();
            }
        });
    }



    public void signIn(){
        if (signDialog.isShowing()){
            signDialog.dismiss();
        }
        try {
            Schedule schedule = db.selector(Schedule.class).where("ID","=",schId).findFirst();
            if (schedule!=null){
                Shop thisShop = db.selector(Shop.class).where("ID","=",schedule.getShopID()).findFirst();
                if (thisShop!=null){
                    shopId = thisShop.getID();
                    double ycol = thisShop.getyCol();
                    double xcol = thisShop.getxCol();
                    Log.e("shopXYCol",ycol+","+xcol);
                    if (MainActivity.signId>0){
                        //签出再签到
                        isneedupdateshopXY=1;
                        signout();

                    }else{
                        //签到
                        if (ycol==0||xcol==0){ //门店无坐标数据
                            isneedupdateshopXY=0;
                            doSignRequest();
                        }else{ //计算坐标差异，用于提示用户
                            isneedupdateshopXY=1;
                            LatLng shoplath = new LatLng(ycol,xcol);
                            //Unable to add window,activity销毁之前进行判断
                            if (!EditEvaluationActivity.this.isFinishing()){
                                showDialog(myPosition,shoplath);
                            }
                        }
                    }
                }
            }else{
                showToast(this,"参数错误");
            }
        } catch (DbException e) {
            e.printStackTrace();
        }
    }


    public String getTime(){
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
        Date date=new Date(System.currentTimeMillis());
        String signTime=formatter.format(date);
        return signTime;
    }



    public void saveData(){ //保存本签到地数据
        final SignUpInfo nsi=new SignUpInfo();
        nsi.setEmpId(MainActivity.id);
        nsi.setIsInRange(isinrange);
        nsi.setInTime(getTime());
        nsi.setShopId(shopId);
        nsi.setXCol(myPosition.longitude);
        nsi.setYCol(myPosition.latitude);
        try{
            db.saveOrUpdate(nsi);
            MainActivity.signId=nsi.get_ID();
        } catch (DbException e) {
            e.printStackTrace();
        }
    }
    //签到数据请求
    public void doSignRequest(){

        Map<String,String> map=new HashMap<>();
        map.put("task","signUpEmployee");
        map.put("empid", MainActivity.id+"");
        map.put("shopid",shopId+"");
        map.put("lat",""+myPosition.latitude);
        map.put("lng",""+myPosition.longitude);
        map.put("isinrange",isinrange+"");//0 小于1000m，1大于1000m
        map.put("isneedupdateshopXY",isneedupdateshopXY+"");//0设置坐标，1门店无坐标
        map.put("checkTime",getTime());
        saveData();
        try {
            OkHttpManger.getInstance().postAsync(pubClass.Server_namehzm, new OkHttpManger.MyCallback() {
                @Override
                public void onSuccess(String result) {
                    String[] strings = result.split("\\|");
                    if (strings[0].equals("201")) {
                        showAnimaDialog(EditEvaluationActivity.this,strings[1]);
                    }else if (strings[0].equals("200")){
                        showAnimaDialog(EditEvaluationActivity.this,"签到成功");
                        final AsynData data=new AsynData(null);
                        new Thread() {
                            @Override
                            public void run() {
                                super.run();
                                try {
                                    data.asynSignUpData(MainActivity.id);
                                } catch (IOException e) {
                                    e.printStackTrace();
                                }
                            }
                        }.start();
                    }else{
                        showToast(EditEvaluationActivity.this,"签到失败");
                        finish();
                    }
                }
                @Override
                public void onFailture() {
                    //离线情况
                    showAnimaDialog(EditEvaluationActivity.this,"签到成功");
                }
            },map);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void showDialog(LatLng myPosition,LatLng shopPosition){
        double Redistance= DistanceUtil.getDistance(myPosition,shopPosition);
        //如果转化失败会返回-1，防止点击进入
        if (Redistance==-1){
            BaseActivity.showAnimaDialog(this,"正在定位，请稍后");
            return;
        }
        if(Redistance>=1000) {
            isinrange = 0;
        }else {
            isinrange = 1;
        }
        //随着定位的更新，避免重复创建dialog
        if (dialog!=null&&dialog.isShowing()){
            Log.e("showDialog","======come in ===");
            if (countText!=null){
                if (Redistance>=1000){
                    double dd=Redistance/1000;
                    double distance=Math.round(dd*10)/10.0;
                    countText.setText(distance+"千米");
                }else{
                    double distance=Math.round(Redistance*10)/10.0;
                    countText.setText(distance+"米");
                }
            }
        } else{
            dialog=new Dialog(this);
            dialog.setCanceledOnTouchOutside(false);
            View view= LayoutInflater.from(this).inflate(R.layout.sign_dialog, (ViewGroup) getWindow().getDecorView(),false);
            countText =  view.findViewById(R.id.countText);
            final TextView doSign=  view.findViewById(R.id.doSign);
            doSign.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                    doSignRequest();
                }
            });
            TextView cancel_action=  view.findViewById(R.id.cancel_action);
            cancel_action.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                    finish();
                }
            });
            if (Redistance>=1000){
                double dd=Redistance/1000;
                double distance=Math.round(dd*10)/10.0;
                countText.setText(distance+"千米");
            }else{
                double distance=Math.round(Redistance*10)/10.0;
                countText.setText(distance+"米");
            }
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setContentView(view);
            dialog.show();
        }



    }

    //用户签出
    protected SignUpInfo sui;
    public void signout()
    {
        try {
            sui = db.selector(SignUpInfo.class).where("_ID", "=", MainActivity.signId + "").findFirst();
            if(sui!=null) {
                sui.setOutTime(BaseActivity.getNowDate());
                Map<String,String> map=new HashMap<>();
                map.put("task","signoutsync");
                map.put("siJson", JSON.toJSONString(sui));
                try {
                    OkHttpManger.getInstance().postAsync(pubClass.Server_namehzm, new OkHttpManger.MyCallback() {
                        @Override
                        public void onSuccess(String result) {
                            String[] array=result.split("\\|");
                            if(array[0].equals("200")) { //迁出成功
                                try {
                                    db.saveOrUpdate(sui);
                                } catch (DbException e) {
                                    e.printStackTrace();
                                }
                                MainActivity.signId=0;
                                //签到
//                                new Thread(){
//                                    @Override
//                                    public void run() {
//                                        super.run();
//                                        doSignRequest();
//                                    }
//                                }.start();
                                signIn();
                            }
                            else
                            {
                                showAnimaDialog(EditEvaluationActivity.this,"签出失败，参数错误");
                                finish();
                            }
                        }
                        @Override
                        public void onFailture() {
                            try {
                                db.saveOrUpdate(sui);
                            } catch (DbException e) {
                                e.printStackTrace();
                            }
                            //离线签到
                            saveData();
                            showToast(EditEvaluationActivity.this,"签到成功");
                        }
                    },map);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }catch (DbException e) {
            e.printStackTrace();
        }
    }


    //提示正在定位中
    ProgressDialog signDialog;
    private void showSignDialog(){
        signDialog = new ProgressDialog(this);
        signDialog.setMessage("正在定位中，请稍后...");
        signDialog.setCanceledOnTouchOutside(false);
        signDialog.show();
    }
}
